//
//  ManageBankCardViewController.m
//  share_business
//
//  Created by baidufz on 2017/9/12.
//  Copyright © 2017年 wyl. All rights reserved.
//

#import "ManageBankCardViewController.h"
#import "UICollectionView+RegisterCell.h"
#import "AddBankCardViewController.h"
#import "BankCardCell.h"

@interface ManageBankCardViewController () <UICollectionViewDataSource, UICollectionViewDelegateFlowLayout>

@property (weak, nonatomic) IBOutlet UICollectionView *collectionView;
@property (weak, nonatomic) IBOutlet UIView *emptyView;
@property (nonatomic, retain) NSMutableArray *cardArray;

@end

@implementation ManageBankCardViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    [self registerCell];
    [self initManageView];
}

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    self.navigationItem.title = @"银行卡管理";
    [self topRightItemButton:[UIImage imageNamed:@"bank_card_add"] title:nil];
}

- (void)registerCell {
    [_collectionView registerCell:[BankCardCell class]];
}

- (void)initManageView {
    _cardArray = [NSMutableArray arrayWithObjects:@"",@"", nil];
    _collectionView.dataSource = self;
    _collectionView.delegate = self;
    if ([_cardArray count] > 0) {
        _emptyView.hidden = YES;
    } else {
        _emptyView.hidden = NO;
    }
}

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
    return 2;
}

- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    BankCardCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([BankCardCell class]) forIndexPath:indexPath];
    [cell setBackgroundImage:[UIImage imageNamed:@"bank_background_zs"]];
    return cell;
}

- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout insetForSectionAtIndex:(NSInteger)section {
    return UIEdgeInsetsMake(10, 10, 10, 10);
}

- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
    return CGSizeMake(ScreenWidth - 20, 130);
}


- (void)rightAction:(UIButton *)button {
    [self.navigationController pushViewController:[AddBankCardViewController new] animated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
